define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'market/market/index' + location.search,
                    // add_url: 'market/market/add',
                    // edit_url: 'market/market/edit',
                    // del_url: 'market/market/del',
                    // multi_url: 'market/market/multi',
                    table: 'market',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'symbol', title: __('Symbol')},
                        {field: 'name', title: __('Name')},
                        {field: 'name_cn', title: __('Name_cn')},
                        {field: 'now_price', title: __('Now_price'), operate:'BETWEEN'},
                        {field: 'now_price_cny', title: __('Now_price_cny'), operate:'BETWEEN'},
                        {field: 'marketcap_cny', title: __('Marketcap_cny')},
                        {field: 'marketcap_rankings', title: __('Marketcap_rankings')},
                        {field: 'turnover', title: __('Turnover')},
                        {field: 'circulation', title: __('Circulation')},
                        {field: 'increase24', title: __('Increase24'), operate:'BETWEEN'},
                        {field: 'vol24', title: __('Vol24')},
                        {field: 'max24', title: __('Max24')},
                        {field: 'min24', title: __('Min24')},
                        // {field: 'exchange24', title: __('Exchange24'), operate:'BETWEEN'},
                        {field: 'issue', title: __('Issue')},
                        {field: 'network', title: __('Network')},
                        {field: 'white_paper', title: __('White_paper')},
                        // {field: 'k_day', title: __('K_day')},
                        // {field: 'k_week', title: __('K_week')},
                        // {field: 'k_month', title: __('K_month')},
                        // {field: 'k_year', title: __('K_year')},
                        {field: 'sort', title: __('Sort')},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});